using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;

namespace Dogfight2008.Tests
{
  [TestFixture]
  public class SetFixture
  {
    [Test]
    public void Construct()
    {
      Set<int> set = new Set<int>();
    }

    [Test]
    public void Add()
    {
      Set<int> set = new Set<int>();
      set.Add(3);
      Assert.AreEqual(1, set.Count);
    }

    [Test]
    public void AddRange()
    {
      Set<string> set = new Set<string>();
      set.AddRange("olof", "bjarnason");
      Assert.AreEqual(2, set.Count);
    }

    [Test]
    public void SecondAdd()
    {
      Set<int> set = new Set<int>();
      set.Add(1);
      set.Add(2);
      Assert.AreEqual(2, set.Count);
    }

    [Test]
    public void Contains()
    {
      Set<int> set = new Set<int>();
      set.Add(1);
      Assert.IsTrue(set.Contains(1));
    }

    [Test]
    public void NotContains()
    {
      Set<int> set = new Set<int>();
      Assert.IsFalse(set.Contains(1));
    }

    [Test]
    public void Remove()
    {
      Set<string> set = new Set<string>();
      set.Add("olof");
      set.Add("bjarnason");
      set.Remove("djdi");
      Assert.AreEqual(2, set.Count);
      set.Remove("olof");
      Assert.AreEqual(1, set.Count);
      Assert.IsTrue(set.Contains("bjarnason"));
    }

    [Test]
    public void Enumerate()
    {
      Set<int> set = new Set<int>();
      set.AddRange(1, 2, 3);
      List<int> exp = new List<int>();
      exp.AddRange(new int[] { 1, 2, 3 });
      CollectionAssert.AreEqual(exp, new List<int>(set));
    }
  }
}
